﻿package com.gamemeal.filters {
	import flash.display.BitmapData;
	import flash.filters.BitmapFilter;
	
	import com.gamemeal.filters.ICustomBitmapFilter;
	import com.gamemeal.geom.GeomUtils;
	/**
	 * @author Colin
	 */
	public class FilterComposition implements ICustomBitmapFilter {
		private var _filters:Array=[];

		public function addFilter(filter:*):void{
			_filters.push(filter);
		}

		public function apply(ctx : BitmapData) : void {
			for(var i:int=0;i<_filters.length;i++){
				if(_filters[i] is BitmapFilter){
					ctx.applyFilter(ctx,ctx.rect, GeomUtils.origin, _filters[i]);
				}else{
					_filters[i].apply(ctx);
				}
			}
		}
	}
}